CREATE PROCEDURE [dbo].[ReportInvoiceByPersonForProjectWithAnyBillStatus]
@ProjectName NVARCHAR (50), @StartDate DATETIME, @EndDate DATETIME
AS
BEGIN
	select u.FullName, p.Name as Project, e.EntryDate, e.Duration, e.BillableHours as Billing, c.Name as Category, pt.Name as ProjectType, pm.HourlyRate, e.Description, e.HasBeenBilled
	from EntryLog e inner join
	     Users u on e.UserID = u.UserID inner join
		 Projects p on e.ProjectID = p.ProjectID inner join
		 Categories c on e.CategoryID = c.CategoryID inner join
		 ProjectMembers pm on pm.ProjectID = p.ProjectID and pm.UserID = u.UserID inner join
		 ProjectTypes pt on pt.ID = p.ProjectTypeID
	where (e.EntryDate between @StartDate and @EndDate) and (p.Name = @ProjectName) and (p.ProjectTypeID = 1 or p.ProjectTypeID = 2)
	order by Project, FullName, EntryDate	
END

